home *** CD-ROM | disk | FTP | other *** search
- { ************************************************************************
- * Program : DialTest.Pas
- *
- * Author : Ian Hayes
- * Soft Systems Ltd,
- * London UK
- * Compuserve id: 100010,1415
- *
- * Description : An adaption of the Borland demo to show
- * drag'n drop lisboxes in action.
- *
- ************************************************************************ }
-
- program DialTest;
-
- {$R DIALTEST.RES}
-
- uses WinTypes, WinProcs, OWindows, ODialogs, DndLb;
-
- const
- TheMenu = 100;
- id_lb1 = 111;
- id_lb2 = 112;
- cm_DialTest = 101;
-
- type
- PTestDialog = ^TTestDialog;
- TTestDialog = object(TDialog)
- lb1,lb2: PDndListBox;
- CONSTRUCTOR Init(AParent: PWindowsObject; AName: PChar);
- PROCEDURE SetupWindow; VIRTUAL;
- end;
-
- PTestWindow = ^TTestWindow;
- TTestWindow = object(TWindow)
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- procedure CMDialTest(var Msg: TMessage); virtual cm_First + cm_DialTest;
- end;
-
- TDlgApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- { TTestDialog }
-
- CONSTRUCTOR TTestDialog.Init(AParent: PWindowsObject; AName: PChar);
- BEGIN
- INHERITED Init(AParent,AName);
- { set up drag-n-drop listboxes so that they delete the
- item from the starting listbox }
- lb1 := NEW(PDndListBox,InitResource(@Self,id_lb1,TRUE));
- lb2 := NEW(PDndListBox,InitResource(@Self,id_lb2,TRUE));
- END;
-
- procedure TTestDialog.SetupWindow;
- var
- TextItem : PChar;
- begin
- INHERITED SetupWindow;
- TextItem := 'Item 1';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- TextItem := 'Item 2';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- TextItem := 'Item 3';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- TextItem := 'Item 4';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- TextItem := 'Item 5';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- TextItem := 'Item 6';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- TextItem := 'Item 7';
- SendDlgItemMsg(id_LB1, lb_AddString, 0, Longint(TextItem));
- end;
-
- { TTestWindow }
- constructor TTestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- inherited Init(AParent, ATitle);
- Attr.Menu := LoadMenu(Hinstance, MakeIntResource(TheMenu));
- end;
-
- procedure TTestWindow.CMDialTest(var Msg: TMessage);
- begin
- Application^.ExecDialog(New(PTestDialog, Init(@Self, 'DIAL1')));
- end;
-
- { TDlgApplication }
- procedure TDlgApplication.InitMainWindow;
- begin
- MainWindow := New(PTestWindow, Init(nil, 'Dialog Tester'));
- end;
-
- var
- MyApp: TDlgApplication;
- begin
- MyApp.Init('DialTest');
- MyApp.Run;
- MyApp.Done;
- end.
-